package likou;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2022/08/12 08:34
 */
public class _1282 {
    public static void main(String[] args) {
        System.out.println(groupThePeople(new int[]{2,2,1,1,1,1,1,1}));
    }
    private static List<List<Integer>> groupThePeople(int[] groupSizes) {
        List<List<Integer>> res = new ArrayList<>();
        int[] nums = new int[501];
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < groupSizes.length; i++) {
            int num = groupSizes[i];
            if (map.containsKey(num)) {
                map.get(num).add(i);
                nums[num]++;
            } else {
                List<Integer> list = new ArrayList<Integer>();
                list.add(i);
                if (num!=1) {
                    map.put(num, list);
                    nums[num]++;
                }
                res.add(list);
            }
        }
        return res;
    }
}
